package ds;

import java.util.LinkedList;
import java.util.List;

/**
 * @Author: zhang
 * @Description:
 * @Date: Created in 0:57 2019/9/19
 */
public class cycleQueue {

}

class MyCircularQueue {

    List<Integer> list = new LinkedList<>();
    int length = 0;
    public MyCircularQueue(int k) {
        length = k; //用一个int值保存要求的表长
    }
    public boolean enQueue(int value) {   //list长度小于length则加入list即可，大于等于则拒绝加入
        if(list.size() >= length) {
            return false;
        }
        list.add(value);
        return true;
    }
    public boolean deQueue() {  //非空则清除list第一项即可
        if(list.isEmpty()) {
            return false;
        }
        list.remove(0);
        return true;
    }
    public int Front() {  //非空返回第一项
        if(list.size() == 0){
            return -1;
        }
        return list.get(0);
    }
    public int Rear() {  //非空返回最后一项
        if(list.size() == 0){
            return -1;
        }
        return list.get(list.size() - 1);
    }
    public boolean isEmpty() {
        return list.isEmpty();
    }
    public boolean isFull() {
        return list.size() == length;
    }
}
